<?php

/**
 * MVM_MALL 网上商店系统 显示文章
 * ============================================================================
 * 版权所有 (C) 2007-2010 www.mvmmall.com，并保留所有权利。
 * 网站地址: http://www.mvmmall.com
 * ----------------------------------------------------------------------------
 * 这是一个免费开源的软件；这意味着您可以在不用于商业目的的前提下对程序代码
 * 进行修改、使用和再发布。
 * ============================================================================
 * $Author:  www.mvmmall.com  $
 * $Date: 2008-06-12 $
 * $Id: article.php  www.mvmmall.com$
 * ---------------------------------------------
*/

require_once 'include/common.inc.php';
require_once MVMMALL_ROOT.'include/board_comm.inc.php';

//浏览权限判断
if($m_check_rank < $mm_board['class_view']) {
    if(!$m_check_id) {
        show_msg('board_grant_list',GetBaseUrl('logging','login'));
    } elseif ($article['board_id']!=$m_check_id) {
        show_msg('board_grant_list_member');
    }
}

//更新浏览数
!is_numeric($id) && show_msg('pass_worng');
if($id!=$_SESSION['mvm_board_view']) {
    $_SESSION['mvm_board_view'] = $id;
    $db->query("UPDATE `{$tablepre}bmain` SET board_hit = board_hit + 1 WHERE uid ='$id'");
}

//cookie记录已经浏览过文章
setcookie("mvm_reply[$id][id]","$id", time()+9999999);
setcookie("mvm_reply[$id][time]","$m_now_time", time()+9999999);


$article['hit']     = $article['board_hit'];
$article['date']    = date($mm_time_format,$article['register_date']);
$article['subject'] = $article['board_subject'];
//$article['conter']  = $article['board_body'];
//小进行下处理by dxd
$article['conter']  = str_replace('&lt;br /&gt;','<br />',$article['board_body']);
//end dxd
$article['ip']      = ($mm_board['use_viewip'] && $m_check_rank > $mm_board['class_view'] )? $article['board_ip'] : false;
$article['name']    = $article['board_email'] ? '<a href=\"mailer.php?action=sendemail&ps_rmail='.mango_encode($article['board_email']).'\" target=\"_blank\">'.$article['board_name'].'</a>' : $article['board_name'];

//显示回复
$reply              = array();
$query_limit        = $mm_board['comment_num'] > '0' ? "LIMIT 0,$mm_board[comment_num]":false;
$result             = $db->query("SELECT * FROM `{$tablepre}bcomment` WHERE fid='$id' ORDER BY `uid` DESC $query_limit");
while($rt = $db->fetch_array($result)) {
    $rt['name']     = $rt['user_name'];
    $rt['conter']   = $rt['reply_body'];
    $rt['subject']  = $rt['reply_subject'];
    $rt['date']     = date($mm_time_format,$rt['register_date']);
    // IP显示... IP隐藏 管理组成员可以看到
    $rt['ip']       = ($mm_board['use_viewip'] && $m_check_rank > $mm_board['class_view'] ) ? $rt['reply_ip'] : false;
    if($m_check_rank >= $mm_board['class_reply'] && $mm_adminid ==1) {
        $rt['del']  = "<a href=\"board_ok.php?ps_mode=reply_delete&action=$action&id=$id&uid=$rt[uid]\" onclick=\"return del_really()\">$lang[uesr_del]</a>";
        $rt['edit'] = "<a href=\"post.php?action=$action&ps_mode=editreply&uid=$rt[uid]\" >$lang[edit_announce]</a>";
    } else {
        $rt['del']  = '';
        $rt['user_id']==$article['board_id'] && $rt['edit'] = "<a href=\"post.php?action=$action&ps_mode=editreply&uid=$rt[uid]\" >$lang[edit_announce]</a>";
    }
    $reply[]        = $rt;
}


$navigation       = make_navigation($mm_board['board_title'],GetBaseUrl('board',$action));//导航
$board_modify_url = "post.php?action=$action&ps_mode=modify&id=$id";
$board_reply_url  = "post.php?action=$action&ps_mode=reply&id=$id";
$mm_mall_title    = $article['board_subject']; //标题
$mm_keywords      = $article['board_subject'].$mm_keywords; //关键字
if ($article['use_secret']==1){
    $mm_adminid==1 ? $mm_description = cut_str(strip_tags($article['board_body']),255) : $article['conter']  = '^_^'.$lang['uesr_secret'].'^_^';
}else {
    $mm_description = cut_str(strip_tags($article['board_body']),255);
}
if($m_check_rank >= $mm_board['class_comment']) {
    $show_comment_type = $m_check_id ? "<b> $lang[uesr_reply] </b> $m_check_name" :"$lang[bbs_uesr_id] <br /><input type=\"text\" name=\"board_name\" class=\"text\" size=\"15\" maxlength=\"15\">";
}
require_once MVMMALL_ROOT . 'header.php';
require_once template('article');
footer();